package com.bawei.library_common.websocket;

import android.util.Log;

import com.bawei.library_common.utils.LoggerUtils;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * @Author : yaotianxue
 * @Time : On 2023/6/28 10:53
 * @Description : YaoWebSocketClient
 */
public class YaoWebSocketClient extends WebSocketClient {

    public YaoWebSocketClient(URI serverUri) {
        super(serverUri,new Draft_6455());
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        LoggerUtils.Companion.d("ytx","建立链接");
    }

    @Override
    public void onMessage(String message) {
        LoggerUtils.Companion.d("ytx","接受到消息"+message);
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        LoggerUtils.Companion.d("ytx","关闭链接");
    }

    @Override
    public void onError(Exception ex) {
        LoggerUtils.Companion.d("ytx","链接失败"+ex.getMessage());
    }
}
